class Utils {
	constructor(arg) {

	}
	static showNetErrorToast(data) {
		if (data == null) {
			data = "网络异常，操作失败";
		}
		uni.showToast({
			title: data,
			duration:6,
		})
	}
	static showNetSuccessToast(data) {
		if (data == null) {
			data = "操作成功";
		}
		uni.showToast({
			title: data
		})
	}

	static showToast(data) {
		if (data == null) {
			data = "操作成功";
		}
		uni.showToast({
			title: data
		})
	}
	
	static showErrorToast(data) {
		if (data == null) {
			data = "操作成功";
		}
		uni.showToast({
			title: data,
			icon:'none',
		})
	}


	static getXt(pt) {
		var content = "";
		if (pt == 1) {
			content = content + "安卓";
		} else if (pt == 2) {
			content = content + "IOS";
		} else {
			content = content + "PC";
		}
		return content;
	}
	
	
	static getckKind(pt) {
		var content = "";
		if (pt == 1) {
			content = "截图";
		} else if (pt == 2) {
			content = "后台";
		} else {
			content="其他";
		}
		return content;
	}
	
	static getLx(pt) {
		var content = "";
		if (pt == 1) {
			content = "个人";
		} else if (pt == 2) {
			content = "公司";
		} else if(pt==3){
			content = "联盟";
		}
		else{
			content = "其它";
		}
		return content;
	}

	static getJsfs(jsfs) {
		var jsString = "";
		if (jsfs == 1) {
			jsString = jsString + "日结";
		} else if (jsfs == 2) {
			jsString = jsString + "周结";
		} else if (jsfs == 3) {
			jsString = jsString + "月结";
		} else {
			jsString = jsString + "其他";
		}
		return jsString;
	}
	static getText(text) {
		if (TextUtils.isEmpty(text)) {
			return "暂无";
		}
		return text.replaceAll("\n", "").replaceAll(" ", "").replaceAll("\r", "").trim() + "";
	}

	static getQdlx(QUDAO_qdlx) {
		var jsString = "其它";
		if (QUDAO_qdlx == 1) {
			jsString = "个人";
		} else if (QUDAO_qdlx == 2) {
			jsString = "公司";
		} else if (QUDAO_qdlx == 3) {
			jsString =  "团队";
		} else if(QUDAO_qdlx == 4){
			jsString =  "联盟";
		}
		return jsString;
	}

	static gettgfs(qudao) {
		var jsString;
		if (qudao == 1) {
			jsString = "网站";
		} else if (qudao == 2) {
			jsString = "应用";
		} else if (qudao == 3) {
			jsString = "联盟";
		} else if (qudao == 4) {
			jsString = "地推";
		} else {
			jsString = "其他";
		}
		return jsString;
	
}

static getTgLx(QUDAO_SSLX) {
	
		var jsString = "";
		if (QUDAO_SSLX == 1) {
			jsString = "安卓软件";
		} else if (QUDAO_SSLX == 2) {
			jsString =  "IOS软件";
		}  else if(QUDAO_SSLX == 3){
			jsString = "PC软件";
		}
		else{
			jsString = "全部";
		}
		return jsString;
	}


static getTimer(stringTime) {
	var minute = 1000 * 60;
	var hour = minute * 60;
	var day = hour * 24;
	var week = day * 7;
	var month = day * 30;
	var time1 = new Date().getTime(); //当前的时间戳
	var time2 = Date.parse(new Date(stringTime)); //指定时间的时间戳
	var time = time1 - time2;

	var result = null;
	if (time < 0) {
		result = stringTime
	} else if (time / month >= 1) {
		result = "" + parseInt(time / month) + "月前";
	} else if (time / week >= 1) {
		result = "" + parseInt(time / week) + "周前";
	} else if (time / day >= 1) {
		result = "" + parseInt(time / day) + "天前";
	} else if (time / hour >= 1) {
		result = "" + parseInt(time / hour) + "小时前";
	} else if (time / minute >= 1) {
		result = "" + parseInt(time / minute) + "分钟前";
	} else {
		result = "刚刚";
	}
	return result;
}


static checkAddCpData(data) {
	if (data.CHANPIN_APPMINGZI == null || data.CHANPIN_APPMINGZI.length < 3) {
		this.showToast("请输入大于3个字的标题");
		return false;
	}
	if (data.CHANPIN_APPJIAGE == null || data.CHANPIN_APPJIAGE == 0) {
		this.showToast("请输入大于0的推广单价");
		return false;
	}
	if (data.CHANPIN_QQHM == null || data.CHANPIN_WXHM == null) {
		this.showToast("QQ和微信至少输入一个");
		return false;
	}
	if (data.CHANPIN_BZ == null || data.CHANPIN_BZ.length < 5) {
		this.showToast("请输入大于5个字的推广详细");
		return false;
	}
	return true;

}


}

export default Utils;
